package com.xyy.saas.payment.adpater.xydLoan.core.constants;

import lombok.Getter;

import java.util.Arrays;
import java.util.List;

@Getter
public enum XydPharmacyTypeEnum {

    RETAIL("0", "零售单体", "1", "单体药店"),

    HEADQUARTERS("1", "药品零售连锁总部（连锁总部）", "21,22", "连锁总部、小连锁总部"),

    FRANCHISE("2", "连锁药店（连锁加盟）", "2,3", "连锁加盟、连锁直营"),

    COMMERCIAL_COMPANY("3", "商业公司", "5,23", "药品批发、批发(商业)"),

    CLINIC("4", "诊所（第三终端）", "4,9,10,14,15", "诊所、社区卫生服务站、卫生室、门诊部、其他医疗机构"),

    OTHER("5", "其他", "6,7,8,16,17,18,19,20", "民营医院、公立医院、卫生院、药品生产、非药类生产、境外企业、非药类经营、其他企业");

    private final String xydCode;

    private final String xydName;

    private final String ybmCode;

    private final String ybmName;

    XydPharmacyTypeEnum(String xydCode, String xydName, String ybmCode, String ybmName) {
        this.xydCode = xydCode;
        this.xydName = xydName;
        this.ybmCode = ybmCode;
        this.ybmName = ybmName;
    }

    /**
     * 默认返回其他
     * @param code
     * @return
     */
    public static String getXydCodeStr(int code) {
        for (XydPharmacyTypeEnum value : XydPharmacyTypeEnum.values()) {
            List<String> list = Arrays.asList(value.getYbmCode().split(","));
            if (list.contains(String.valueOf(code))) {
                return value.getXydCode();
            }
        }
        return OTHER.getXydCode();
    }
}
